# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=fbida
pkgver=2.14
pkgrel=5
pkgdesc="Few applications to display and elementary edit images"
url="https://www.kraxel.org/blog/linux/$pkgname/"
arch="all"
license="GPL-2.0-only"
makedepends="freetype-dev fontconfig-dev libdrm-dev libexif-dev
	libpng-dev tiff-dev giflib-dev pixman-dev linux-headers perl
	libepoxy-dev motif-dev"
subpackages="
	$pkgname-fbgs:_tool:noarch
	$pkgname-exiftran:_tool
	$pkgname-fbi:_tool
	$pkgname-ida:_tool
	$pkgname-doc
	"
source="https://www.kraxel.org/releases/fbida/fbida-$pkgver.tar.gz
	no-pdf.patch
	ida-desktop.patch
	gcc-10.patch
	"

prepare() {
	default_prepare
	echo $pkgver > VERSION
}

build() {
	make verbose=yes -C "$builddir"
}

package() {
	make DESTDIR="$pkgdir" RESDIR="/etc/X11/app-defaults/$pkgname" \
		prefix=/usr -C "$builddir" install
}

_tool() {
	local name=$(echo $subpkgname | cut -d '-' -f2)
	pkgdesc="$name tool from $pkgname"

	depends=""
	if [ "$name" = "fbgs" ]; then
		depends="$pkgname-fbi ghostscript"
	fi

	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/$name \
		"$subpkgdir"/usr/bin/$name

	if [ "$name" = "ida" ]; then
		mv "$pkgdir"/etc/ "$subpkgdir"/etc/
		install -Dm644 "$builddir"/desktop/ida.desktop "$subpkgdir"/usr/share/applications/ida.desktop
	fi

	rmdir "$pkgdir"/usr/bin/ 2>/dev/null || true
	rmdir "$pkgdir"/usr/ 2>/dev/null || true
}

sha512sums="8f3596ad8a22497880ac698d3b324e038ac5ccae7481fe4a902fc6e8bf43ba1bb3a96af8c7a3347bea86c1988f35674e2647901ac256bd4e8261d467a6a343ec  fbida-2.14.tar.gz
972b55541755b4b2abfe9ef3fd50e2003851b4b1798c9dafbd98d9e5b02f0508f9326b3a87c23a600d759cd3dcd4c6826844d3017f39efe1187bb741a2dcc7b9  no-pdf.patch
cd5276b558a15f34353ebc5a51bd092142c1f5194e98d11c2ed22f4731200899fb31b95f52f884bc06a9e1fc5f9762c124e0870415a4a7e787548f19d12915e5  ida-desktop.patch
eb4f649e50fe5da682729d7aefa10c471145a5df9290251f973b21b8636f8d88bb2b97dbf913c8e7089edd8617326e50f822e160566f63b1e2baf8ee2ac6e64a  gcc-10.patch"
